<#include "./template/general_temp.ftl">

<#macro content>
<div class="row">
    <div class="box col-md-12">
        <div class="box-inner">
            <div class="box-header well" data-original-title="">
                <h2><i class="glyphicon glyphicon-posts"></i>相似度匹配</h2>

                <div class="box-icon">
                    <a href="#" class="btn btn-setting btn-round btn-default"><i class="glyphicon glyphicon-cog"></i></a>
                    <a href="#" class="btn btn-minimize btn-round btn-default"><i
                            class="glyphicon glyphicon-chevron-up"></i></a>
                    <a href="#" class="btn btn-close btn-round btn-default"><i class="glyphicon glyphicon-remove"></i></a>
                </div>

            <div class="box-content" id="box-content">
                <div class="alert alert-info box col-md-12">
                    <div class="box">
                        <form role="form">
                            <table>
                                <tr>
                                    <td>
                                        <label class="control-label" for="trappedPersonNum">井下被困人数：</label>
                                    </td>
                                    <td><input type="number" required="required" name="trappedPersonNum" class="form-control" id="trappedPersonNum" placeholder=""></td>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                </tr>
                                <tr>
                                    <td>
                                        <label class="control-label" for="explosionMin">爆炸规模下限(%)：</label>
                                    </td>
                                    <td>
                                        <input type="number" name="explosionMin" required="required" class="form-control" id="explosionMin" placeholder="">
                                    </td>
                                    <td>
                                        <label class="control-label" for="explosionMax">爆炸规模上限(%)：</label>
                                    </td>
                                    <td>
                                        <input type="number" name="explosionMax" required="required" class="form-control" id="explosionMax" placeholder="">
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <label class="control-label" for="coMin">CO体积分数下限(万分之)：</label>
                                    </td>
                                    <td>
                                        <input type="number" name="coMin" required="required" class="form-control" id="coMin" placeholder="">
                                    </td>
                                    <td>
                                        <label class="control-label" for="coMax">CO体积分数上限(万分之)：</label>
                                    </td>
                                    <td>
                                        <input type="number" name="coMax" required="required" class="form-control" id="coMax" placeholder="">
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <label class="control-label" for="gasMin">瓦斯含量下限(%)：</label>
                                    </td>
                                    <td>
                                        <input type="number" name="gasMin" required="required" class="form-control" id="gasMin" placeholder="">
                                    </td>
                                    <td>
                                        <label class="control-label" for="gasMax">瓦斯含量上限(%)：</label>
                                    </td>
                                    <td>
                                        <input type="number" name="gasMax" required="required" class="form-control" id="gasMax" placeholder="">
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <label class="control-label" for="ventilationMin">通风系统破坏程度下限(%)：</label>
                                    </td>
                                    <td>
                                        <input type="number" name="ventilationMin" required="required" class="form-control" id="ventilationMin" placeholder="">
                                    </td>
                                    <td>
                                        <label class="control-label" for="ventilationMax">通风系统破坏程度上限(%)：</label>
                                    </td>
                                    <td>
                                        <input type="number" name="ventilationMax" required="required" class="form-control" id="ventilationMax" placeholder="">
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <label class="control-label" for="collapseMin">坍塌情况下限(%)：</label>
                                    </td>
                                    <td>
                                        <input type="number" name="collapseMin" required="required" class="form-control" id="collapseMin" placeholder="">
                                    </td>
                                    <td>
                                        <label class="control-label" for="collapseMax">坍塌情况上限(%)：</label>
                                    </td>
                                    <td>
                                        <input type="number" name="collapseMax" required="required" class="form-control" id="collapseMax" placeholder="">
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <label class="control-label" for="secondaryExplosionMin">二次爆炸危害下限(%)：</label>
                                    </td>
                                    <td>
                                        <input type="number" name="secondaryExplosionMin" required="required" class="form-control" id="secondaryExplosionMin" placeholder="">
                                    </td>
                                    <td>
                                        <label class="control-label" for="secondaryExplosionMax">二次爆炸危害上限(%)：</label>
                                    </td>
                                    <td>
                                        <input type="number" name="secondaryExplosionMax" required="required" class="form-control" id="secondaryExplosionMax" placeholder="">
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <label class="control-label" for="fireHazard">是否引起火灾：</label>
                                    </td>
                                    <td>
                                        <select name="fireHazard" class="form-control" required="required" id="fireHazard">
                                            <option value="1">是</option>
                                            <option value="0">否</option>
                                        </select>
                                    </td>
                                    <td>
                                        &nbsp;
                                    </td>
                                    <td>
                                        &nbsp;
                                    </td>
                                </tr>
                                <tr>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                    <td>
                                        <button type="button" onclick="queryData()" class="btn btn-default"><i class="glyphicon glyphicon-search"></i>计算一下</button>
                                    </td>
                                    <td>&nbsp;</td>
                                </tr>
                            </table>
                        </form>
                    </div>
                </div>
                <table id="posts_dg">
                </table>
            </div>
            </div>
        </div>
    </div>
    <!--/span-->

</div><!--/row-->
</#macro>
<#macro script>
<script type="text/javascript">
    function getQueryCondition(){
        var trappedPersonNum = $("#trappedPersonNum").val();
        var explosionMin = $("#explosionMin").val();
        var explosionMax = $("#explosionMax").val();
        var coMin = $("#coMin").val();
        var coMax = $("#coMax").val();
        var gasMin = $("#gasMin").val();
        var gasMax = $("#gasMax").val();
        var ventilationMin = $("#ventilationMin").val();
        var ventilationMax = $("#ventilationMax").val();
        var collapseMin = $("#collapseMin").val();
        var collapseMax = $("#collapseMax").val();
        var secondaryExplosionMin = $("#secondaryExplosionMin").val();
        var secondaryExplosionMax = $("#secondaryExplosionMax").val();
        var fireHazard = $("#fireHazard").val();
        return {"trappedPersonNum":trappedPersonNum,"explosionMin":explosionMin,"explosionMax":explosionMax,
            "coMin":coMin,"coMax":coMax,"gasMin":gasMin,"gasMax":gasMax,"ventilationMin":ventilationMin,"ventilationMax":ventilationMax,
            "collapseMin":collapseMin,"collapseMax":collapseMax,"secondaryExplosionMin":secondaryExplosionMin,"secondaryExplosionMax":secondaryExplosionMax,
            "fireHazard":fireHazard};
    }
    function queryData(){
        var pars=getQueryCondition();
        var resetCss={
            checkbox:'position: absolute;left: 30px;top: 10px;',
            button:'margin-left: 80px;'
        };
        //构造列表
        jQuery('#posts_dg').datagrid({
            url:'${base}/system/baseInfo/calculate',
            fitColumns : true,
            striped : true,
            pagination : true,
            rownumbers : true,
            pageSize : 20,
            pageNumber : 1,
            pageList : [ 10,20, 50],
            loadMsg : '数据正在加载中...',
            singleSelect:true,
            queryParams : pars,
            selectOnCheck : false,
            checkOnSelect : false,
            width:$('.box-content').width() * 0.985,
            columns : [[
                {field : 'name', title : '案例名称（点击进入详情页面）',  resizable : true, hidden : false, sortable : false, width:$(this).width()*0.04, align: 'center'},
                {field : 'similar', title : '相似度',  resizable : true, hidden : false, sortable : false, width:$(this).width()*0.01, align: 'center'}
            ]],
            onLoadSuccess:function(data){
            },
            onClickRow: function (rowIndex, rowData) {
                window.location = "${base}/system/baseInfo/edit?id=" + rowData.id;
            }
        });
    }

    $(document).ready(function () {
        queryData();
    });

    function edit(id){
        window.location = "${base}/system/baseInfo/edit?id=" + id;
    }

    function del(id){
        if(window.confirm("确认删除？")) {
            jQuery.ajax({
                type: "POST",
                url: '${base}/system/baseInfo/delete',
                dataType:"json",
                data: {"id": id},
                success: function(data){
                    if(data.status == 1) {
                        alert("删除成功！");
                        queryData();
                    }
                },
                error: function (obj){
                    console.info(obj);
                }
            });
        }
    }
</script>
</#macro>
